from rest_framework import serializers

from app import models


class MySerializer(serializers.ModelSerializer):
    class Meta:

        model = models.UserInfo

        fields = ['uid', 'username', 'password']

        depth = 0
        extra_kwargs = {
            'username': {
                'min_length': 2,
                'max_length': 12,
                'error_messages': {
                    'min_length': '6个字符',
                    'max_length': '12个字符',
                },
            },
            'password': {
                'help_text': '密码６－８位',
            }
        }

class MySerializer1(serializers.ModelSerializer):
    class Meta:

        model = models.UserInfo

        fields = ['id', 'username', 'password']

        extra_kwargs = {
            'id': {
                'help_text': 'uid',
            }
        }
